package com.ruoyi.algorithm.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.algorithm.entity.Algorithm;
import com.ruoyi.algorithm.mapper.AlgorithmMapper;
import com.ruoyi.algorithm.model.AlgorithmListModel;
import com.beihu.sightplus.common.repository.BaseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AlgorithmRepository extends BaseRepository<AlgorithmMapper, Algorithm> {

    @Autowired
    private AlgorithmMapper algorithmMapper;
    /**
     * 根据算子Id查询算法信息
     */
    public List<Algorithm> getByOperatorId(Long operatorId){
        LambdaQueryWrapper<Algorithm> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Algorithm::getOperatorId, operatorId);
        return algorithmMapper.selectList(wrapper);
    }

    /**
     * 分页条件查询
     */
    public Page<AlgorithmListModel> listByPage(List<Map<String, Object>> list, String orderAttr, String orderType, Long current, Long size){
        IPage<AlgorithmListModel> page = new Page<>(current, size);
        return algorithmMapper.listByPage(page, list, orderAttr, orderType);
    }
}
